package com.example.zhangpeng.recyclerviewclick;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private RecyclerView rvContent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rvContent = (RecyclerView) findViewById(R.id.rv_content);
        rvContent.setLayoutManager(new LinearLayoutManager(this));
        String []strings=new String[20];
        for(int i=0;i<20;i++){
            strings[i]="你好夜晚"+i;
        }
        MyAdapter myAdapter=new MyAdapter(strings);
        rvContent.setAdapter(myAdapter);
        myAdapter.setOnItemClickListner(new MyAdapter.OnRecyclerViewListner() {
            @Override
            public void setOnItemClickListner(View v, String str) {
                Toast.makeText(MainActivity.this,str,Toast.LENGTH_SHORT).show();
            }
        });

    }


}
